<template>
	<div>

		<!-- <div style="background-color: #f4f5f6;padding-top: 33px;margin-top:20px;">
			<el-form ref="form" :inline="true" :model="formInline" label-width="80px">
				<el-form-item label="名称" placeholder="搜索名称/编号进行查询">
					<el-input v-model="formInline.userName"></el-input>
				</el-form-item>
				<el-form-item label="状态">
					<el-select v-model="formInline.goodName">
						<el-option label="区域一" value="shanghai"></el-option>
						<el-option label="区域二" value="beijing"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" @click="findContent(1)">查询</el-button>
					<el-button @click="findContent(1)">重置</el-button>
				</el-form-item>
			</el-form>
		</div> -->
		<el-row :span="24" style="margin:26px 0 0;">
			<div style="display: flex;justify-content: flex-start;">
				<p class="tabHeader" style="color: #409eff;border-bottom: 0;">首页</p>
				<p @click="goMerchantOperation()" class="tabHeader">商家</p>
				<p @click="navToPersonal()" class="tabHeader">个人中心</p>
				<p @click="navToCkBanner()" class="tabHeader">创客</p>
				<p @click="navToStartBanner()" class="tabHeader">启动广告</p>
				<p @click="navTocity()" class="tabHeader">城主页面</p>
			</div>
			<el-row style="margin-top: 20px;">
				<el-button @click="edit('addSY')" class="btnPad " type="primary">新增</el-button>
				<el-button @click="getBannerList()" :class="[isActive==true?'btnChoose':'btnPad'] " plain>banner</el-button>
				<el-button @click="getOperationList()" :class="[isActive2==true?'btnChoose':'btnPad'] " plain>运营位</el-button>
				<el-button @click="getImportantList()" :class="[isActive1==true?'btnChoose':'btnPad'] " plain>主功能区</el-button>

				<el-button @click="getInviteProductList()" :class="[isActive3==true?'btnChoose':'btnPad'] " plain>商品推荐</el-button>
				<!-- <el-button @click="getHotelList()" :class="[isActive4==true?'btnChoose':'btnPad'] " plain>酒店推荐</el-button> -->
			</el-row>
		</el-row>
		<!-- 首页banner -->
		<el-table v-if="isActive == true" :data="pageInfo.vos" v-loading="table_loading" element-table_loading-text="加载中"
		 stripe style="width: 100%;margin-top: 20px;">
			<el-table-column width="150" label="图片">
				<template scope="scope">
					<img class="banner" :src="scope.row.bannerIcon">
				</template>
			</el-table-column>
			<el-table-column prop="bannerName" label="名称">
			</el-table-column>
			<el-table-column label="排序值" prop="banner_Sort" width="115" sortable='custom'>
				<template scope="scope">
					<el-input v-model="scope.row.bannerSort" style="width: 80px;" @blur="editOrder(scope.row,$event)" @focus="setOldProbability(scope.row)"></el-input>
				</template>
			</el-table-column>
			<el-table-column label="跳转类型">
				<template scope="scope">
					<span>{{ findState(scope.row.bannerType,bannerType) }}</span>
				</template>
			</el-table-column>
			<el-table-column sortable='custom' prop="CRE_TIME" label="创建时间">
				<template scope="scope">
					<span>{{dateFormat(scope.row.creTime,'y-m-d h:i')}}</span>
				</template>
			</el-table-column>
			<el-table-column label="操作" width="250">
				<template scope="scope">
					<el-button size="small" type="primary" @click="edit(scope.row.bannerCode)">编辑
					</el-button>
					<el-button size="small" type="danger" @click="handleDetele(scope.row.bannerCode)">删除
					</el-button>
					<el-button size="small" :type="scope.row.bannerState=='Y'?'danger':'success'" @click="using(scope.row)">{{scope.row.bannerState=='Y'?'禁用':'启用'}}
					</el-button>
				</template>
			</el-table-column>
		</el-table>
		<div v-if="isActive == true" class="paginate">
			<el-pagination @current-change="handleCurrentChangeBanner" :current-page="pageInfo.pageNum" :page-size="pageInfo.pageSize"
			 layout="total, prev, pager, next, jumper" :total="pageInfo.count">
			</el-pagination>
		</div>
		<div style="margin-top: 20px;">
			<!-- 运营位 -->
			<el-table v-if="isActive2 == true" :data="position_Info.dtos" v-loading="table_loading" element-table_loading-text="加载中"
			 stripe style="width: 100%">
				<el-table-column width="250" prop="operationName" label="名称">
				</el-table-column>
				<el-table-column label="图片">
					<template scope="scope">
						<img v-for="item in scope.row.icons" style="width: 80px;margin: 5px;" class="banner" :src="item">
					</template>
				</el-table-column>
				<el-table-column label="跳转类型">
					<template scope="scope">
						<span>{{scope.row.operationImage }}</span>
					</template>
				</el-table-column>
				<!-- 运营位 -->
				<el-table-column label="操作" width="250">
					<template scope="scope">
						<el-button size="small" type="primary" @click="editOperation(scope.row.operationCode)">编辑
						</el-button>

					</template>
				</el-table-column>
			</el-table>
			<div v-if="isActive2 == true" class="paginate">
				<el-pagination @current-change="handleCurrentChangeOperation" :current-page="pageInfo.pageNum" :page-size="pageInfo.pageSize"
				 layout="total, prev, pager, next, jumper" :total="pageInfo.count">
				</el-pagination>
			</div>
			<div v-if="isActive1 == true">
				<!-- 主功能区 -->
				<el-table :data="position_Info.homes" v-loading="table_loading" element-table_loading-text="加载中" stripe style="width: 100%">
					<el-table-column label="序号" type="index" width="70">
					</el-table-column>
					<el-table-column width="250" prop="sysRemark" label="名称">
					</el-table-column>
					<el-table-column min-width="500" label="图片展示">
						<template scope="scope">
							<img style="width: 80px;margin: 5px;" class="banner" :src="scope.row.sysValue">
						</template>
					</el-table-column>
					<el-table-column min-width="100" label="跳转类型">
						<template scope="scope">
							<span>{{scope.row.sysLink}}</span>
						</template>
					</el-table-column>
					<el-table-column label="操作" width="250">
						<template scope="scope">
							<el-button size="small" type="primary" @click="edit2(scope.row)">编辑
							</el-button>

						</template>
					</el-table-column>
				</el-table>
			</div>
			<!-- 商品推荐 -->
			<div v-if="isActive3 == true" class="customer">
				<el-form :model="form" style="background-color: #FFFFFF;">
					<el-form-item label="选择商品：" label-width="120px">
						<el-button size="small" type="primary" @click="fetchGoods(1);dialogTableVisible=true">点击选择
						</el-button>
					</el-form-item>
					<el-form-item label="选择套餐：" label-width="120px">
						<el-button size="small" type="primary" @click="fetchVoucher(1);dialogTableVisible4=true">点击选择
						</el-button>
					</el-form-item>

				</el-form>
				<el-table :data="pageInfo2.rows" style="margin-bottom: 20px;width:100%">
					<el-table-column label="排序值" width="110">
						<template scope="scope">
							<el-button @click="setOldProbability(scope.row,scope.row.sort_value);showDilog(scope.row)">{{ scope.row.sort_value }}</el-button>
						</template>
					</el-table-column>
					<el-table-column width="300" label="商品名称">
						<template scope="scope">
							<div style="display: inline-block;">
								<img class="banner" :src="scope.row.goodCover" style="width:120px;">
							</div>
							<div style="display: inline-block;width: 120px;vertical-align: middle;padding: 10px;">{{scope.row.goodName}}</div>
						</template>
					</el-table-column>
					<el-table-column min-width="150" prop="good_Price" label="价格（元）">
						<template scope="scope">
							<span>{{ scope.row.goodPrice }}</span>
						</template>
					</el-table-column>
					<el-table-column min-width="150" label="操作">
						<template scope="scope">
							<el-button @click.native.prevent="deleteRow(scope.$index,scope.row.goodId)" type="danger" size="small">
								删除
							</el-button>
						</template>
					</el-table-column>
				</el-table>
				<div class="paginate">
					<el-pagination @current-change="handleCurrentChange2" :current-page="pageInfo2.pageNum" :page-size="pageInfo2.pageSize"
					 layout="total, prev, pager, next, jumper" :total="pageInfo2.count">
					</el-pagination>
				</div>
				</el-row>
				<div style="margin-left: 30px;margin-bottom: 20px;">
					<el-button type="primary" @click="submit()" :loading="loading">保 存 商 品
					</el-button>
				</div>
				<!--选择商品-->
				<el-dialog title="选择商品" v-model="dialogTableVisible" size="large">
					<el-row>
						<el-col :span="24">
							<el-form :inline="true" class="demo-form-inline" label-width="80px">
								<el-form-item label="商品名称">
									<el-col :span="18">
										<el-input v-model="formInline.goodName"></el-input>
									</el-col>
								</el-form-item>
								<el-button type="primary" @click="fetchGoods(1)">查询</el-button>
							</el-form>
						</el-col>
					</el-row>
					<el-table :data="gridData">
						<el-table-column width="215" label="商品">
							<template scope="scope">
								<div style="display: inline-block;">
									<img class="banner" :src="scope.row.goodCover" style="width:55px;">
								</div>
								<div style="display: inline-block;width: 120px;vertical-align: middle;padding: 10px;">{{scope.row.goodName}}</div>
							</template>
						</el-table-column>
						<el-table-column prop="DIS_PRICE" label="分类">
							<template scope="scope">
								<span>{{ scope.row.goodOneCateName }} - {{ scope.row.goodTwoCateName }}</span>
							</template>
						</el-table-column>
						<el-table-column prop="good_Price" sortable='custom' label="起售价（元）">
							<template scope="scope">
								<span>{{ scope.row.goodPrice }}</span>
							</template>
						</el-table-column>
						<el-table-column prop="T1.good_Discount_Price" label="优惠价（元）">
							<template scope="scope">
								<span v-if="scope.row.goodIsDiscount==1">{{ scope.row.goodDiscountPrice }}</span>
								<span v-else>未启用</span>
							</template>
						</el-table-column>
						<el-table-column prop="good_Ratio" label="补贴比例">
							<template scope="scope">
								<span>{{ scope.row.goodRatio*100 }}%</span>
							</template>
						</el-table-column>
						<el-table-column prop="sales" label="销量">
						</el-table-column>
						<el-table-column prop="stock" label="库存">
						</el-table-column>
						<el-table-column prop="cre_Time" label="上架时间">
							<template scope="scope">
								<span>{{scope.row.creTime}}</span>
							</template>
						</el-table-column>
						<el-table-column label="选择" width="150">
							<template scope="scope">
								<el-checkbox-group v-model="checked" :max="100" @change="handleCheckedCitiesChange">
									<el-checkbox :label="scope.row">选择</el-checkbox>
								</el-checkbox-group>
							</template>
						</el-table-column>
					</el-table>
					<div class="paginate" style="float: left;" @click.stop>
						<el-pagination @current-change="handleCurrentChange_list" :current-page="pageInfo.pageNum" :page-size="pageInfo.pageSize"
						 layout="total, prev, pager, next, jumper" :total="pageInfo.count">
						</el-pagination>
					</div>
					<div style="float: right;margin-top:19px;margin-right: 20px;">
						<el-checkbox v-model="checkAll" @change="handleCheckAllChange" style="margin-right: 40px;" :indeterminate="isIndeterminate">全选</el-checkbox>
						<el-button type="primary" @click="onSubmit()">确定</el-button>
					</div>
				</el-dialog>

				<!--选择套餐-->
				<el-dialog title="选择消费服务" v-model="dialogTableVisible4" size="large">
					<el-table :data="gridData">
						<el-table-column label="封面">
							<template scope="scope">
								<img class="banner" :src="scope.row.voucherCover" style="width: 120px">
							</template>
						</el-table-column>
						<el-table-column prop="voucherName" label="消费服务名称">
						</el-table-column>
						<el-table-column prop="voucherAmt" label="价格">
						</el-table-column>
						<el-table-column prop="voucherSunNum" label="销量">
						</el-table-column>
						<el-table-column prop="voucherNum" label="库存">
						</el-table-column>
						<el-table-column label="有效期">
							<template scope="scope">
								<span>{{ scope.row.voucherStartTime }}至{{ scope.row.voucherEndTime }}</span>
							</template>
						</el-table-column>
						<el-table-column label="选择" width="150">
							<template scope="scope">
								<el-checkbox-group v-model="checked" :max="100" @change="handleCheckedCitiesChange">
									<el-checkbox :label="scope.row">选择</el-checkbox>
								</el-checkbox-group>
							</template>
						</el-table-column>
					</el-table>
					<div class="paginate" style="float: left;" @click.stop>
						<el-pagination @current-change="handleCurrentChangeTC" :current-page="pageInfo3.pageNum" :page-size="pageInfo3.pageSize"
						 layout="total, prev, pager, next, jumper" :total="pageInfo3.count">
						</el-pagination>
					</div>
					<div style="float: right;margin-top:19px;margin-right: 20px;">
						<el-checkbox v-model="checkAll" @change="handleCheckAllChange" style="margin-right: 40px;" :indeterminate="isIndeterminate">全选</el-checkbox>
						<el-button type="primary" @click="onSubmit(3)">确定</el-button>
					</div>
				</el-dialog>
			</div>
		</div>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				activeName: 'first',
				isActive: true,
				isActive1: false,
				isActive2: false,
				isActive3: false,
				isActive4: false,
				pageInfo: {
					pageNum: 1,
					pageSize: 10,
					count: 1,
					dtos: []
				},
				pageInfo3: {
					pageNum: 1,
					pageSize: 10,
					count: 1,
					dtos: []
				},
				table_loading: false,
				formInline: {
					goodName: '',
					goodOneCate: '',
					goodTwoCate: '',
					goodState: 2,
					storeId: '',
					pageNum: 1,
					pageSize: 5,
					sort: 'T1.CRE_TIME',
					desc: 'DESC',
					goodIsDiscount: ''
				},
				pageInfo2: {
					pageNum: 1,
					pageSize: 5,
					count: 1,
					rows: []
				},
				form: {
					goodsCodeList: [],
					operationCode: 5
				},
				desc: 'DESC',
				sorts: 'BANNER_SORT + 0',
				position_Info: [],
				radio1: '首页',
				radio2: '商家',
				radio3: '我的',
				radio4: '创客',
				radio5: '启动广告',
				bannerType: [{
						text: '单商品',
						value: 'D'
					}, {
						text: '多商品',
						value: 'DD'
					}, {
						text: '链接',
						value: 'L'
					}, {
						text: '商家',
						value: 'DP'
					}, {
						text: '文章',
						value: 'T'
					}, {
						text: '不跳转',
						value: 'B'
					},
					{
						text: '商家入驻',
						value: 'S'
					},
				],
				dialogTableVisible: false,
				dialogTableVisible2: false,
				dialogTableVisible3: false,
				dialogTableVisible4: false,
				storeGoodDtos: [],
				loading: false,
				gridData: [],
				checked: [],
				checkAll: false,
				isIndeterminate: true,

			}
		},
		created() {

		},
		activated() {
			this.getBannerList(this.pageInfo.pageNum);
			if (sessionStorage.getItem('bannerIcon')) {
				this.getImportantList()
				sessionStorage.removeItem('bannerIcon')
			}
			if (sessionStorage.getItem('homeYuny')) {
				this.getOperationList()
				sessionStorage.removeItem('homeYuny')
			}
		},
		mounted() {

		},
		methods: {
			handleCurrentChangeBanner(val) {
				this.getBannerList(val)
			},
			handleCurrentChangeOperation(val) {
				this.getOperationList(val)
			},
			handleCurrentChangeImportant(val) {
				this.getImportantList(val)
			},
			navToPersonal() {
				/**
				 * 方法说明
				 * author: liuchen
				 * description:
				 * @param 前往个人中心
				 * @return
				 * @createTime: 2020-8-6 18:42:09
				 */
				this.$router.push('/official/personal_center')
			},
			navToCkBanner() {
				/**
				 * 方法说明
				 * author: liuchen
				 * description:
				 * @param 前往创客
				 * @return
				 * @createTime: 2020-8-7 14:43:16
				 */
				this.$router.push('/official/ck_bannerList')
			},
			navToStartBanner() {
				/**
				 * 方法说明
				 * author: liuchen
				 * description:
				 * @param 前往开机广告
				 * @return
				 * @createTime: 2020-8-6 18:42:09
				 */
				this.$router.push('/official/start_bannerList')
			},
			navTocity() {
				this.$router.push('/official/city_master')
			},
			fetchData(page = 1) {
				if (this.startTime && this.endTime) {
					this.formInline.startTime = dateFormat(this.startTime)
					this.formInline.endTime = dateFormat(this.endTime)
					if (this.formInline.startTime > this.formInline.endTime) {
						this.$message({
							type: 'warning',
							message: '开始时间不能大于结束时间'
						});
						return;
					}
				} else {
					this.formInline.startTime = ''
					this.formInline.endTime = ''
				}
				this.table_loading = true;
				this.pageInfo.pageNum = page
				this.formInline.pageNum = page
				this.formInline.orderStat = this.activeName
				this.formInline[this.formInline.type] = this.formInline.name
				this.dataApi.ajax('selectPageWebShopOrder', this.formInline, res => {
					this.table_loading = false;
					if (res.responseType === 'S') {
						this.pageInfo = res
					}
				});

			},
			handleClick(tab, event) {
				console.log(tab, event);
			},
			submitLogistic() {
				this.dataApi.ajax('MallOrderControl/editOrderInfo', {
					logisticsCompany: this.form.logisticsCompany,
					courierNo: this.form.courierNo,
					orderId: this.form.orderId
				}, res => {
					if (res.responseType === 0) {
						this.fetchData(this.pageInfo.pageNo)
						this.dialogVisible3 = false
						this.showMsg('修改成功')
					}
				});
			},
			findContent(page = 1) {
				console.log(page)
			},
			getBannerList(page = 1) {
				/**
				 * 方法说明
				 * author: liuchen
				 * description: 首页运营banner列表
				 * @param
				 * @return
				 * @createTime: 2020/8/6
				 */
				let vm = this
				vm.verifyIsActive(1)
				vm.table_loading = true;
				vm.pageInfo.pageNum = page
				vm.dataApi.ajax('bannerPage', {
					pageNum: vm.pageInfo.pageNum,
					pageSize: 10,
					sort: vm.sorts,
					desc: vm.desc,
					bannerPosition: 'SY'
				}, res => {
					// console.log(res, '首页banner列表')
					this.table_loading = false;
					if (res.responseType === 'S') {
						this.pageInfo = res
					}
				});

			},
			verifyIsActive(page) {
				let vm = this
				if (page == 1) {
					vm.isActive = true
					vm.isActive1 = false
					vm.isActive2 = false
					vm.isActive3 = false
					vm.isActive4 = false
				}
				if (page == 2) {
					vm.isActive = false
					vm.isActive1 = true
					vm.isActive2 = false
					vm.isActive3 = false
					vm.isActive4 = false
				}
				if (page == 3) {
					vm.isActive = false
					vm.isActive1 = false
					vm.isActive2 = true
					vm.isActive3 = false
					vm.isActive4 = false
				}
				if (page == 4) {
					vm.isActive = false
					vm.isActive1 = false
					vm.isActive2 = false
					vm.isActive3 = true
					vm.isActive4 = false
				}
				if (page == 5) {
					vm.isActive = false
					vm.isActive1 = false
					vm.isActive2 = false
					vm.isActive3 = false
					vm.isActive4 = true
				}

			},
			handleCurrentChangeTC(val) {
				this.fetchVoucher(val)
			},
			edit(id) {

				this.$router.push('/official/banner_list_detail/' + id)
			},
			handleDetele(id) {
				/**
				 * 方法说明
				 * author: liuchen
				 * description: banner删除
				 * @param
				 * @return
				 * @createTime: 2020-8-6 13:50:17
				 */
				this.$confirm('确定删除?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					this.dataApi.ajax('bannerDelete', {
						bannerCode: id
					}, res => {
						if (res.responseType === 'S') {
							this.showMsg('删除成功');
							this.getBannerList(this.pageInfo.pageNum);
						}
					});
				}).catch(() => {

				});

			},
			using(item) {
				/**
				 * 方法说明
				 * author: liuchen
				 * description:
				 * @param 禁用启用
				 * @return
				 * @createTime: 2020-8-6 14:15:13
				 */
				var type = ''
				var state = ''
				let data = generateObj(item)
				if (data.bannerState == 'Y') {
					type = '禁用'
					state = 'J'
				} else {
					type = '启用'
					state = 'Y'
				}
				data.bannerState = state
				this.$confirm('确定' + type + '?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					this.dataApi.ajax('bannerEdit', data, res => {
						if (res.responseType === 'S') {
							this.showMsg(type + '成功')
							this.getBannerList(this.pageInfo.pageNum)
						}
					});
				}).catch(() => {

				});
			},
			getImportantList() {
				/**
				 * 方法说明
				 * author: liuchen
				 * description: 新运营位、主功能区
				 * @param
				 * @return
				 * @createTime: 2020-8-6 10:29:38
				 */
				let vm = this
				let type = 'home'
				vm.verifyIsActive(2)
				vm.dataApi.ajax('newSinglePerson', {
					type: type
				}, res => {
					vm.table_loading = false;
					if (res.responseType === 'S') {
						console.log('==========',res)
						var position_Info = res
						var arr = position_Info.dtos
						vm.position_Info = position_Info

					}
				});

			},
			edit2(data) {
				let isShow = true
				sessionStorage.setItem('bannerIcon', JSON.stringify(isShow))
				this.$router.push({
					path: "/official/edit_activityBanner/",
					query: {
						data: data
					}
				})
				// this.$router.push('/official/edit_activityBanner/' + data)
			},
			getOperationList() {
				/**
				 * 方法说明
				 * author: liuchen
				 * description: 主功能列表
				 * @param
				 * @return
				 * @createTime: 2020-8-6 11:47:40
				 */
				let vm = this
				vm.verifyIsActive(3)
				vm.dataApi.ajax('operationList', {}, res => {
					//console.log(res)
					vm.table_loading = false;
					if (res.responseType === 'S') {
						var position_Info = res
            console.log('==========',res)
						vm.position_Info = position_Info
					}
				});
			},
			editOperation(data) {
				this.$router.push('/official/new_index_detail/' + data)
			},
			getInviteProductList() {
				/**
				 * 方法说明
				 * author: liuchen
				 * description:商品列表
				 * @param
				 * @return
				 * @createTime: 2020-8-6 13:18:20
				 */
				let vm = this
				vm.verifyIsActive(4)
				vm.dataApi.ajax('operationSelect', {
					operationCode: vm.form.operationCode
				}, res => {
					// console.log(this.form.operationCode,'Code')
					// console.log(res)
					if (res.responseType === 'S') {
						vm.pageInfo2 = {
							pageNum: 1,
							pageSize: 5,
							count: 1,
							rows: []
						}
						for (var i = res.dtos.length - 1; i >= 0; i--) {
							res.dtos[i].sort_value = i + 1
							res.dtos[i].index = i
							res.dtos[i].OldProbability = i + 1
						}
						let arr = generateArr(res.dtos)
						vm.storeGoodDtos = res.dtos
						vm.pageInfo2.count = res.dtos.length
						vm.pageInfo2.rows = arr.splice(0, 5)
					}
				});
			},
			deleteRow(index, id) {
				this.pageInfo2.rows.splice(index, 1);
				// this.storeGoodDtos.splice(index, 1);
				for (var i = this.storeGoodDtos.length - 1; i >= 0; i--) {
					if (this.storeGoodDtos[i].goodId.indexOf(id) !== -1) {
						this.storeGoodDtos.splice([i], 1)
					}
				}
				for (var i = this.storeGoodDtos.length - 1; i >= 0; i--) {
					this.storeGoodDtos[i].sort_value = i + 1
					this.storeGoodDtos[i].index = i
					this.storeGoodDtos[i].OldProbability = i + 1
				}
				this.handleCurrentChange2(this.pageInfo2.pageNum)
				this.pageInfo2.count = this.storeGoodDtos.length
			},
			handleCurrentChange2(val) {
				this.pageInfo2.pageNum = val
				// console.log(arr.splice(5*(val-1),(5*(val-1)+5)))
				var arr2 = []
				var arr = generateArr(this.storeGoodDtos)
				arr2 = arr.slice(5 * (val - 1), (5 * (val - 1) + 5))
				this.pageInfo2.rows = arr2
			},
			fetchGoods(page = 1) {
				this.checked = []
				this.pageInfo.pageNum = page;
				this.formInline.pageNum = page;
				this.dataApi.ajax('selectPageStoreGood', this.formInline, res => {
					if (res.responseType === 'S') {
						this.pageInfo = res
						this.gridData = res.dtos
						this.arr = []
						this.checked = []
						this.inisIndeterminate = true
						for (var i = this.gridData.length - 1; i >= 0; i--) {
							this.arr.push(this.gridData[i])
						}

						if (this.checked.length == this.arr.length) {
							this.checkAll = true
						} else {
							this.checkAll = false;
						}

					}
				});
			},

			handleCurrentChange_list(val) {
				/**
				 * 方法说明
				 * author: liuchen
				 * description: 选择商品
				 * @param
				 * @return
				 * @createTime: 2020-9-17 15:21:00
				 */
				this.fetchGoods(val)
				this.checkAll = false
			},
			handleCheckAllChange(event) {

				if (event.target.checked == false) {
					for (var i = this.arr.length - 1; i >= 0; i--) {
						for (var j = this.checked.length - 1; j >= 0; j--) {
							if (this.arr.indexOf(this.checked[j]) !== -1) {
								this.checked.splice(j, 1)
							}
						}
					}

				} else {
					this.isIndeterminate = false;
					for (var i = this.gridData.length - 1; i >= 0; i--) {
						if (this.checked.indexOf(this.arr[i]) === -1) {
							this.checked.push(this.arr[i])
						}
					}
				}


			},
			handleCheckedCitiesChange(value) {

				let arr = []
				for (var i = this.arr.length - 1; i >= 0; i--) {
					for (var j = this.checked.length - 1; j >= 0; j--) {
						if (arr.indexOf(this.checked[j]) === -1 && this.arr[i] === this.checked[j]) {
							arr.push(this.checked[j])
						}
					}
				}


				let checkedCount = arr.length;
				this.checkAll = checkedCount === this.arr.length;
				this.isIndeterminate = checkedCount > 0 && checkedCount < this.arr.length;
			},
			onSubmit(type) {

				// this.pageInfo2.rows=this.checked
				for (var key in this.storeGoodDtos) {
					for (var i in this.checked) {
						if (type == 1) {
							if (this.storeGoodDtos[key].goodId.indexOf(this.checked[i].goodId) !== -1) {
								this.checked.splice([i], 1)
							}
						} else if (type == 2) {
							if (this.storeGoodDtos[key].goodId.indexOf(this.checked[i].roomId) !== -1) {
								this.checked.splice([i], 1)
							}
						} else if (type == 3) {
							if (this.storeGoodDtos[key].goodId.indexOf(this.checked[i].voucherId) !== -1 && this.storeGoodDtos[key].goodId != undefined) {
								this.checked.splice([i], 1)
							}
						}

					}
				}
				if (this.checked.length <= 0) {
					return false;
				}
				this.storeGoodDtos = this.storeGoodDtos.concat(this.checked);
				// -----------------------------------
				// console.log(this.storeGoodDtos,'this.storeGoodDtos')
				for (var i = this.storeGoodDtos.length - 1; i >= 0; i--) {
					this.storeGoodDtos[i].sort_value = i + 1;
					this.storeGoodDtos[i].index = i;
					this.storeGoodDtos[i].OldProbability = i + 1;
					if (!this.storeGoodDtos[i].goodId && type == 3) {
						this.storeGoodDtos[i]['goodId'] = this.storeGoodDtos[i].voucherId;
						this.storeGoodDtos[i]['goodName'] = this.storeGoodDtos[i].voucherName;
						this.storeGoodDtos[i]['goodCover'] = this.storeGoodDtos[i].voucherCover;
						this.storeGoodDtos[i]['goodPrice'] = this.storeGoodDtos[i].voucherAmt;
						this.storeGoodDtos[i]['goodType'] = type;
					}
				}


				var arr = generateArr(this.storeGoodDtos)
				this.pageInfo2.count = this.storeGoodDtos.length

				this.pageInfo2.rows = arr.splice(0, 5)
				this.dialogTableVisible = false;
				this.dialogTableVisible3 = false;
				this.dialogTableVisible4 = false;

			},
			submit() {
				if (this.form.goodsCodeList.length < 1) {
					this.form.goodsCodeList = ''
				}
				let obj = generateObj(this.form)

				if (this.storeGoodDtos.length == 0) {
					this.$message({
						type: 'warning',
						message: '请选择至少一个商品!'
					});
					return;
				}

				var arr = []
				for (var i = 0; i < this.storeGoodDtos.length; i++) {
					arr.push({
						goodId: this.storeGoodDtos[i].goodId,
						goodType: this.storeGoodDtos[i].goodType ? this.storeGoodDtos[i].goodType.toString() : 1
					})
				}
				obj.dtos = arr
				this.loading = true
				this.dataApi.ajax('operationEdit', obj, res => {
					if (res.responseType === 'S') {
						this.showMsg('保存成功')
						this.loading = false;
						this.getInviteProductList();
					}
				});

			},
			getHotelList() {
				/**
				 * 方法说明
				 * author: liuchen
				 * description:
				 * @param 获取酒店列表
				 * @return
				 * @createTime: 2020-8-6 14:56:53
				 */
				let vm = this
				vm.verifyIsActive(5)
			},
			goMerchantOperation() {
				/**
				 * 方法说明
				 * author: liuchen
				 * description:
				 * @param NavTo商家页
				 * @return
				 * @createTime: 2020-8-6 15:17:58
				 */
				this.$router.push('/official/merchantOperation')
			},

			fetchVoucher(page = 1) {
				/**
				 * 方法说明
				 * author: liuchen
				 * description:
				 * @param 选择套餐
				 * @return
				 * @createTime: 2020-9-3 09:22:18
				 */
				this.checked = []
				this.gridData = []
				this.pageInfo3.pageNum = page;
				if(this.pageInfo3.pageNum == '1') {
					this.pageInfo3.pageSize = 5
					this.pageInfo3.count = 1
					this.gridData = []
					console.log(this.gridData)
				}
				this.dataApi.ajax('selectPagePayStoreVoucher', {
					pageNum: this.pageInfo3.pageNum,
					pageSize: 5,
					sort: 'VOUCHER_AMT',
					desc: 'DESC',
					voucherStat: 1,
					voucherType: '2'
				}, res => {
					if (res.responseType === 'S') {
						this.pageInfo3 = res
						this.gridData = res.dtos
						this.arr = []
						this.checked = []
						this.inisIndeterminate = true
						for (var i = this.gridData.length - 1; i >= 0; i--) {
							this.arr.push(this.gridData[i])
						}
						if (this.checked.length == this.arr.length) {
							this.checkAll = true
						} else {
							this.checkAll = false;
						}

					}
				});
			},

		}
	}
</script>

<style>
	.tabHeader {
		width: 100px;
		text-align: center;
		display: inline-block;
		padding: 5px 10px;
		margin: 0;
		border: 1px solid #909399;
		border-right: 0;
		cursor: pointer;
	}

	.tabHeader:last-child {
		width: 100px;
		text-align: center;
		display: inline-block;
		padding: 5px 10px;
		margin: 0;
		border: 1px solid #909399;
	}

	.el-radio-button__orig-radio:checked+.el-radio-button__inner {
		border-bottom-color: #FFFFFF;
		background-color: #FFFFFF;
		color: #20a0ff;
	}

	.btnPad {
		width: 120px;
		text-align: center;
	}

	.btnChoose {
		width: 120px;
		text-align: center;
		border: 1px solid #20a0ff;
		color: #20a0ff;
	}
</style>
